package sbc.corso;

import org.xvsm.api.core.Capi;
import org.xvsm.api.core.ContainerRef;
import org.xvsm.api.core.CoordinationTypes;
import org.xvsm.client.ClientCapi;

import sbc.corso.shareable.Platine;
import sbc.ms.Producer;
import sbc.ms.Util;

public class Benchmark {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		

	    Capi capi;
	    ContainerRef cref;
	    String url = args[0];
	    
		try	{	
			/*
			 * get Mozart Space Container
			 */
			capi = new ClientCapi(url);
			capi.init(false);
			cref = Util.getOrCreateNamedContainer(capi, "Container", CoordinationTypes.FIFO);
			
			/*
			 * take every tupel out of Mozart Space
			 */
			//Taker myTaker = new Taker(capi, cref);
			//myTaker.start();
			
			//addListener(this);
			
			System.out.println("Logistik gestartet.");
		}
		catch (Exception e)	{
			System.out.println("e: " + e);
		}	
		
		
		for (int i = 0; i < 3; i++)	{
			
        	sbc.model.Platine myPlatine1= new sbc.model.Platine();
    		myPlatine1.setMyId("a"+i);

    		Producer p = new Producer(url, myPlatine1);
    		p.start();

			System.out.println("Platine a" + i + " in den MozartSpace geschrieben.");
	    }	
		
	
		for (int i = 0; i < 5; i++)	{
		
	    	sbc.model.Sensor mySensor1= new sbc.model.Sensor();
			mySensor1.setMyId("s"+i);
	
			Producer p = new Producer(url, mySensor1);
			p.start();
	
			System.out.println("Sensor s" + i + " in den MozartSpace geschrieben.");
        }	
	}

	

}
